package com.imooc.coupon.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * <h1>优惠卷分类</h1>
 * @Author: crowsjian
 * @Date: 2020/6/1 20:40
 */
@Getter
@AllArgsConstructor
public enum CouponCategory {
    MANJIAN("满减卷","001"),
    ZHEKOU("折扣卷","002"),
    LIJIAN("立减卷","003"),
    ;
    private String description;//优惠卷描述信息
    private String code;//优惠卷分类编码
    public static CouponCategory of(String code){
        Objects.requireNonNull(code);
        return Stream.of(values())
                .filter(bean->bean.code.equals(code))
                .findAny()
                .orElseThrow(()->new IllegalArgumentException(code + "not exists!"));
    }
}
